package com.zhudi.develop_demo_as.ui.activity;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.widget.TextView;

import com.zhudi.develop_demo_as.BaseActivity;
import com.zhudi.develop_demo_as.R;
import com.zhudi.develop_demo_as.adapter.ViewpagerAdapter;
import com.zhudi.develop_demo_as.ui.fragment.order.BookTypeFragment;
import com.zhudi.develop_demo_as.widget.SlidingTabLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

public class BookActivity extends BaseActivity {
    private Context context;
    @Bind(R.id.tvTitle)
    TextView tvTitle;
    @Bind(R.id.tab_layout)
    SlidingTabLayout tabLayout;
    @Bind(R.id.view_pager)
    ViewPager viewPager;

    private List<String> mTitles = new ArrayList<String>();
    private List<Fragment> viewpagerFragmentList = new ArrayList<Fragment>();
    @Override
    protected int getLayoutView() {
        return R.layout.activity_book;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = this;
        initView();
    }

//    @Override
//    protected void c(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        context = this;
//        initView();
//    }

    private void initView() {
        tvTitle.setText("外卖单");
        mTitles.add("全部");
        viewpagerFragmentList.add(BookTypeFragment.newInstance("0"));
        mTitles.add("相互关注");
        viewpagerFragmentList.add(BookTypeFragment.newInstance("1"));
        mTitles.add("朋友圈");
        viewpagerFragmentList.add(BookTypeFragment.newInstance("2"));
        mTitles.add("特别");
        viewpagerFragmentList.add(BookTypeFragment.newInstance("3"));
        mTitles.add("同学");
        viewpagerFragmentList.add(BookTypeFragment.newInstance("4"));

        ViewpagerAdapter adapter = new ViewpagerAdapter(getSupportFragmentManager(), viewpagerFragmentList, mTitles);
        viewPager.setAdapter(adapter);
        //tabLayout.setupWithViewPager(viewPager);
        //tabLayout.setTabsFromPagerAdapter(adapter);

        tabLayout.setViewPager(viewPager);
    }
}
